<?php

namespace App\Models;

class NationalityModel
{
    /**
     * 获取国籍列表
     * entry $NationalityExample
     * return array
     * */
    public static function getNationalityList($conn){
        $sql = "SELECT `id`,`country`,`img`,`language` FROM `nationality` WHERE `state` = 1  order by `sort` desc";
        return $conn->readConn($sql, true);
    }
    /**
     * 修改订单
     * entry $CartExample
     * return int
     * */
    public static function editCartInside($conn,$CartExample){
        $joinSql="";
        if($CartExample->addrid !=null){
            $joinSql.=" `addrid` = '$CartExample->addrid',";
        }
        if($CartExample->pay_type !=null){
            $joinSql.=" `pay_type` = '$CartExample->pay_type',";
        }
        if($CartExample->remarks !=null){
            $joinSql.=" `remarks` = '$CartExample->remarks',";
        }
        if($CartExample->stime !=null){
            $joinSql.=" `stime` = $CartExample->stime,";
        }
        if($CartExample->status !=null){
            $joinSql.=" `status` = '$CartExample->status',";
        }
        if($CartExample->courier_number !=null){
            $joinSql.=" `courier_number` = '$CartExample->courier_number',";
        }
        if($CartExample->type !=null){
            $joinSql.=" `type` = '$CartExample->type',";
        }
        if($joinSql !=null){
            $innerJoin = rtrim($joinSql,",");
            $upUserSql="UPDATE  `cart` SET $innerJoin WHERE `id` in($CartExample->id) and `uid` = $CartExample->uid";
            return $conn->executeConn($upUserSql);
        }
    }
}